;NSIS Modern User Interface
;Capture Server Install Script
;Written by Danny Deng

;--------------------------------
;Include Modern UI
  !include "MUI.nsh"

XPStyle on

;--------------------------------
;General

  ;Name and file
  Name "myseelite capture setup"
  OutFile "myseelite_capture_setup.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES\openmysee\capture"

;--------------------------------
;Interface Configuration

;--------------------------------
;Pages
  !define MUI_HEADERIMAGE
  !define MUI_HEADERIMAGE_BITMAP "openmysee.bmp"
  !insertmacro MUI_PAGE_LICENSE "license.txt"
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "openmysee capture" SecDummy

  ;Store installation folder
  SetOutPath "$INSTDIR"
  SetOverwrite on
  File GVCapture.exe
  File MMSServer.exe
  File GetZZL.dll
  File GetZZLDisplay.exe
  File CaptureServer.ax
  File FVideoOverlay.ax
  File graphedt.exe
  SetOverwrite off
  File CaptureServer.cfg
  
  SetOutPath "$SYSDIR"
  SetOverwrite off
  File mfc71.dll
  File msvcp71.dll
  File msvcr71.dll

  RegDLL "$INSTDIR\CaptureServer.ax"
  RegDLL "$INSTDIR\FVideoOverlay.ax"

  CreateDirectory "$SMPROGRAMS\openmysee"
  CreateDirectory "$SMPROGRAMS\openmysee\capture"
  CreateShortCut "$SMPROGRAMS\openmysee\capture\MMSServer.lnk" "$INSTDIR\MMSServer.exe" ; use defaults for parameters, icon, etc.
  CreateShortCut "$SMPROGRAMS\openmysee\capture\GVCapture.lnk" "$INSTDIR\GVCapture.exe" ; use defaults for parameters, icon, etc.
  CreateShortCut "$SMPROGRAMS\openmysee\capture\ZZLConverter.lnk" "$INSTDIR\GetZZLDisplay.exe" ; use defaults for parameters, icon, etc.
  CreateShortCut "$SMPROGRAMS\openmysee\capture\graphedt.lnk" "$INSTDIR\graphedt.exe" ; use defaults for parameters, icon, etc.
  CreateShortCut "$SMPROGRAMS\openmysee\capture\CaptureServer.cfg.lnk" "$INSTDIR\CaptureServer.cfg" ; use defaults for parameters, icon, etc.
  CreateShortCut "$SMPROGRAMS\openmysee\capture\Uninstall.lnk" "$INSTDIR\Uninstall.exe" ; use defaults for parameters, icon, etc.

  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"

SectionEnd

;--------------------------------
;Descriptions

  ;Language strings
  LangString DESC_SecDummy ${LANG_ENGLISH} "openmysee capture utils can open a TV channel on internet."

  ;Assign language strings to sections
  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
  !insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;ADD YOUR OWN FILES HERE...
  
  UnRegDLL "$INSTDIR\CaptureServer.ax"
  UnRegDLL "$INSTDIR\FVideoOverlay.ax"

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\openmysee\capture\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\openmysee\capture"
  RMDir "$SMPROGRAMS\openmysee"

  ; Remove installed files
  Delete "$INSTDIR\GVCapture.exe"
  Delete "$INSTDIR\MMSServer.exe"
  Delete "$INSTDIR\GetZZL.dll"
  Delete "$INSTDIR\GetZZLDisplay.exe"
  Delete "$INSTDIR\CaptureServer.ax"
  Delete "$INSTDIR\FVideoOverlay.ax"
  Delete "$INSTDIR\graphedt.exe"
  Delete "$INSTDIR\CaptureServer.cfg"

  ; Remove temporary files
  Delete "$INSTDIR\ConfigFilter.dat"
  Delete "$INSTDIR\MMSControl.ini"
  Delete "$INSTDIR\*.tmp"

  Delete "$INSTDIR\Uninstall.exe"
  RMDir "$INSTDIR"

SectionEnd
